package com.zb.entity;

import com.zb.annotation.NumberPattern;
import com.zb.utils.VerificUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author WEN
 * @Date 2023/11/7 0007
 **/
@Data
@ApiModel("字段值对象")
public class FieldValVo {
    @ApiModelProperty(value = "ID，新增不必传，修改必传")
    private Long id;

    @ApiModelProperty(value = "原字段表ID")
    private Long fieldId;

    @NumberPattern(regexp = VerificUtil.FIELD_TYPE, message = "字段类型参数不合法")
    @ApiModelProperty(value = "字段类型：1-文本，2-多行文本，3-单选，4-多选，5-多图，6-附件，7-视频，8-评分")
    private Integer type;

    @Length(max = 10, message = "字段名称长度限制 10 个字符")
    @ApiModelProperty(value = "字段名称")
    private String name;

    @Valid
    @ApiModelProperty(value = "字段选项值对象")
    private List<FieldValOptionVo> optVos;

    public FieldValVo() {
    }

    public FieldValVo(String name, List<FieldValOptionVo> optVos) {
        this.name = name;
        this.optVos = optVos;
    }

    public FieldValVo(Long id, Long fieldId, Integer type, String name, List<FieldValOptionVo> optVos) {
        this.id = id;
        this.fieldId = fieldId;
        this.type = type;
        this.name = name;
        this.optVos = optVos;
    }
}
